home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 July / EnigmA AMIGA RUN 20 (1997)(G.R. Edizioni)(IT)[!][issue 1997-07 & 08][EAR-CD IV].iso / earcd / dev / mui / muiplusp.lha / Examples / HTMLtext.cpp next >
C/C++ Source or Header  |  1997-03-23  |  5KB  |  150 lines

  1. /* A simple test and demonstration program using the HTMLtext custom class
  2.    through C++ */
  3.  
  4.  
  5. #define MUIPP_DEBUG         // Turn debugging mode on for invalid use of classes
  6. //#define MUIPP_NOINLINES       // No inlines makes code compile quicker but the resulting
  7.                             // executable is larger and slower. Best to use this
  8.                             // option when developing and turn off for final release.
  9.  
  10. #include <mui/HTMLtext_mcc.hpp>
  11.  
  12. struct IntuitionBase *IntuitionBase = NULL;
  13. struct Library *MUIMasterBase = NULL;
  14.  
  15. int
  16. main (void)
  17. {
  18.     // Open libraries required
  19.  
  20.     if ((IntuitionBase = (struct IntuitionBase *)OpenLibrary ("intuition.library", 0)) == NULL)
  21.     {
  22.         printf ("Could not open intuition.library\n");
  23.         return 10;
  24.     }
  25.  
  26.     if ((MUIMasterBase = OpenLibrary ("muimaster.library", 0)) == NULL)
  27.     {
  28.         printf ("Could not open muimaster.library\n");
  29.         return 10;
  30.     }
  31.  
  32.     CMUI_Window window;
  33.     CMUI_HTMLtext html;
  34.     CMUI_String htmlString;
  35.     CMUI_String htmlURL;
  36.  
  37.     // Create Application object. I am not using any shortcuts here to create
  38.     // the objects. I actually prefer the layout like this than when using
  39.     // shortcuts. If you prefer the old way of creating objects by using the
  40.     // shortcuts then you can still do this. See the shortcuts.cpp example
  41.     // for details as some shortcuts have had to change name so as not to clash
  42.     // with class member functions.
  43.  
  44.     CMUI_Application app
  45.     (
  46.         MUIA_Application_Title, "HTMLtext test",
  47.         MUIA_Application_Author, "Nicholas Allen",
  48.         MUIA_Application_Base, "TEST",
  49.         MUIA_Application_Copyright, "AllenSoft",
  50.         MUIA_Application_Description, "Test Program For HTMLtext C++ class",
  51.         MUIA_Application_Version, "$VER: Test 1.0 (17.9.96)",
  52.         SubWindow, window = CMUI_Window
  53.         (
  54.             MUIA_Window_Title, "Test Program For HTML C++ class",
  55.             MUIA_Window_ID, 10,
  56.             WindowContents, CMUI_VGroup
  57.             (
  58.                 Child, CMUI_Scrollgroup
  59.                 (
  60.                     MUIA_Scrollgroup_Contents, html = CMUI_HTMLtext
  61.                     (
  62.                         MUIA_HTMLtext_Contents, "<b><center><h1>Test for HTMLtext class</b></center></h1>",
  63.                         VirtualFrame,
  64.                         TAG_DONE
  65.                     ),
  66.                     MUIA_CycleChain, 1,
  67.                     TAG_DONE
  68.                 ),
  69.  
  70.                 Child, htmlURL = CMUI_String
  71.                 (
  72.                     MUIA_String_Contents, "",
  73.                     MUIA_ShortHelp, "Enter a URL here!",
  74.                     MUIA_CycleChain, 1,
  75.                     StringFrame,
  76.                     TAG_DONE
  77.                 ),
  78.  
  79.                 Child, htmlString = CMUI_String
  80.                 (
  81.                     MUIA_String_Contents, "",
  82.                     MUIA_ShortHelp, "Enter some HTML text here!",
  83.                     MUIA_CycleChain, 1,
  84.                     StringFrame,
  85.                     TAG_DONE
  86.                 ),
  87.  
  88.                 TAG_DONE
  89.             ),
  90.             TAG_DONE
  91.         ),
  92.         TAG_DONE
  93.     );
  94.  
  95.     // Any MUI object created as a C++ class can be tested for validity by
  96.     // calling its IsValid() method. This method just checks that the
  97.     // BOOPSI object pointer is not NULL.
  98.  
  99.     if (!app.IsValid())
  100.     {
  101.         printf ("Could not create application!\n");
  102.         return 10;
  103.     }
  104.  
  105.     // Setup close window notification.
  106.     // Because Notify() is a variable args method we have to pass sva as the
  107.     // first parameter. Failing to do this will result in an error at
  108.     // COMPILE time so there won't be any weird crashes by forgetting to do
  109.     // this.
  110.  
  111.     window.Notify(sva, MUIA_Window_CloseRequest, TRUE,
  112.                   app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
  113.  
  114.     htmlString.Notify(sva, MUIA_String_Acknowledge, MUIV_EveryTime,
  115.                       html, 3, MUIM_Set, MUIA_HTMLtext_Contents, MUIV_TriggerValue);
  116.  
  117.     htmlURL.Notify(sva, MUIA_String_Acknowledge, MUIV_EveryTime,
  118.                    html, 3, MUIM_Set, MUIA_HTMLtext_URL, MUIV_TriggerValue);
  119.  
  120.     window.SetOpen(TRUE);
  121.  
  122.     ULONG sigs = 0;
  123.     BOOL running = TRUE;
  124.  
  125.     while (running)
  126.     {
  127.         switch (app.NewInput(&sigs))
  128.         {
  129.             case MUIV_Application_ReturnID_Quit:
  130.                 running = FALSE;
  131.             break;
  132.         }
  133.  
  134.         if (sigs)
  135.         {
  136.             sigs = Wait (sigs | SIGBREAKF_CTRL_C);
  137.             if (sigs & SIGBREAKF_CTRL_C) break;
  138.         }
  139.     }
  140.  
  141.     // This disposes of the application and all windows and objects in the
  142.     // windows.
  143.  
  144.     app.Dispose();
  145.  
  146.     CloseLibrary ((struct Library *)IntuitionBase);
  147.     CloseLibrary (MUIMasterBase);
  148.  
  149.     return 0;
  150. }